package physics.component;

import java.awt.Color;
import java.awt.Graphics2D;
import physics.Simulation;


/**
 * A rigid connection between two masses. This is, however, just a more rigid
 * spring.
 *
 * @author Kevin Gao, Connor Gordon
 */

public class Bar extends Spring {

    /**
     * Constant for a bar's k-value (springyness).
     */
    public static final double BAR_K_CONSTANT = 10;

    /**
     * Constructor for a Bar. No k constant is necessary; it is defined as a
     * constant in the Bar class. Also, the rest length given is not necessary
     * because it is dependent on the distance between the two masses the bar
     * connects.
     *
     * @param start
     *        One of the masses that the bar connects to
     * @param end
     *        The other mass that the bar connects to
     */
    public Bar (final Mass start, final Mass end) {
        super(start, end, start.getDistanceBetween(end), BAR_K_CONSTANT);
    }

    @Override
    public final void update (final Simulation canvas, final double dt) {
        determineCurrentPosition();
        super.update(canvas, dt);
    }

    @Override
    protected final void determineColor (final Graphics2D pen) {
        pen.setColor(Color.GREEN);
    }

}
